﻿@{
    ViewData["Title"] = "广告位管理";
    Layout = "~/Areas/Manager/Views/Shared/_Layout.cshtml";
}
<div class="layui-fluid">
    <div class="layui-row layui-col-space15">
        <div class="layui-col-md12">
            <div class="layui-card">
                <div class="layui-card-header">广告位置</div>
                <div class="layui-card-body">
                    <div class="layui-form">
                        <div class="layui-row">
                            <div class="layui-form-item">
                                <div class="layui-col-md3" style="padding-left:0">
                                    <div class="input-group">
                                        <input type="text" id="keyWords" name="keyWords" placeholder="请输入广告位置名称" autocomplete="off" class="layui-input">
                                        <span class="input-group-btn">
                                            <button class="layui-btn" id="search">
                                                <i class="layui-icon layui-icon-search"></i>
                                            </button>
                                        </span>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="layui-row">
                        <div class="layui-btn-container">
                            <div class="layui-btn-group">
                                <button id="add" class="layui-btn layui-btn-sm"><i class="layui-icon">&#xe654;</i>增加</button>
                                <button id="deleteAll" class="layui-btn layui-btn-sm layui-btn-danger"><i class="layui-icon">&#xe640;</i>删除</button>
                            </div>
                        </div>
                    </div>
                    <div class="layui-row">
                        <table class="layui-table" lay-data="{ page:true, id:'list'}" lay-filter="list">
                            <thead>
                                <tr>
                                    <th lay-data="{checkbox:true, fixed: true}"></th>
                                    <th lay-data="{field:'advPositionId',width:120}">广告位ID</th>
                                    <th lay-data="{field:'advPositionName'}">广告位名称</th>
                                    <th lay-data="{field:'showType',templet: '#showType',width:250}">显示类型</th>
                                    <th lay-data="{field:'createDate',width:300}">添加时间</th>
                                    <th lay-data="{toolbar:'#tableoption',width:250}">操作</th>
                                </tr>
                            </thead>
                        </table>
                        <script type="text/html" id="showType">
                            {{#  if(d.showType==0){ }}
                            <span>纵向平铺</span>
                            {{#  } else if(d.showType==1){ }}
                            <span>横向平铺</span>
                            {{#  } else if(d.showType==2){ }}
                            <span>层叠显示</span>
                            {{#  } else if(d.showType==3){ }}
                            <span>交替显示</span>
                            {{#  } else if(d.showType==4){ }}
                            <span>自定义广告代码</span>
                            {{#  } }}
                        </script>
                        <script type="text/html" id="toAdvertisementIndex">
                            <span><a href="AdvertisementIndex?advPositionId={{=d.advPositionId }}">设置广告内容</a></span>
                        </script>
                        <script type="text/html" id="tableoption">
                            <a class="layui-btn layui-btn-normal layui-btn-xs" lay-event="edit"><i class="layui-icon layui-icon-edit"></i>编辑</a>
                            <a href="AdvertisementIndex?advPositionId={{=d.advPositionId }}" class="layui-btn layui-btn-warm layui-btn-xs"><i class="layui-icon layui-icon-edit"></i>设置广告内容</a>
                        </script>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

@section scriptsfeet
    {
    <script type="text/javascript">
        layui.config({
            base: '/layuiadmin/' //自定义模块路径
        }).use(['sykjwh','table'], function () {
            var $ = layui.$, sykjwh = layui.sykjwh, table = layui.table;

            //绑定数据
            sykjwh.dataBind('@Url.Action("AdpositionList", "Ad", new { area = Constant.AREAMANAGER })');

            //添加
            $("#add").click(function () {
                sykjwh.open('添加广告位', '@Url.Action("AdpositionAdd", "Ad", new { area = Constant.AREAMANAGER })', 700, 320);
            });

            //批量删除
            $("#deleteAll").click(function () {
                sykjwh.batOperate('@Url.Action("AdpositionDeleteAll", "Ad", new { area = Constant.AREAMANAGER })', 'advPositionId');
            });

            //监听表格行
            table.on('tool(list)', function (obj) {
                var data = obj.data;//获得当前行数据
                console.log(data);
                if (obj.event === 'edit') {
                    console.log("data.advPositionId:" + data.advPositionId);
                    sykjwh.open('编辑广告位', '@Url.Action("AdpositionEdit", "Ad", new { area = Constant.AREAMANAGER })/' + data.advPositionId, 700, 320);
                }
            });

            //搜索
            $("#search").click(function () {
                //绑定数据
                sykjwh.dataBind('@Url.Action("AdpositionList", "Ad", new { area = Constant.AREAMANAGER })', {
                    keyWords: $.trim($("#keyWords").val())
                });
            });
        });
    </script>
}
